#!/bin/sh
# - test_memory_size
# - nr_task

## The Linpack Benchmark is a measure of a computer’s floating-point rate of execution. It is
## determined by running a computer program that solves a dense system of linear equations.
## See: http://www.netlib.org/utk/people/JackDongarra/faq-linpack.html#_Toc27885709

. $LKP_SRC/lib/job.sh
load_job_vars memory

. $LKP_SRC/lib/upload.sh
. $LKP_SRC/lib/unit.sh
. $LKP_SRC/lib/reproduce-log.sh

cd $BENCHMARK_ROOT/linpack || die "no $BENCHMARK_ROOT/linpack"

if [ -z "$test_memory_size" ]; then
	test_memory_size=$(($(to_byte $memory) / 2))
	max_mem=$((32<<30))
	[ "$test_memory_size" -gt "$max_mem" ] && test_memory_size=$max_mem
fi

dimension=$(echo "sqrt ($test_memory_size * 0.9 / 8)" | bc)

echo "test_memory_size=$test_memory_size dimension=$dimension"

[ -n "$nr_task" ] && export MKL_NUM_THREADS="$nr_task"

cat > lininput_xeon64 <<EOF
Sample Intel(R) Optimized LINPACK Benchmark data file (lininput_xeon64)
Intel(R) Optimized LINPACK Benchmark data
1		# number of tests
$dimension	# problem sizes
$dimension	# leading dimensions
1		# times to run a test
4		# alignment values (in KBytes)"
EOF

upload_files -t results lininput_xeon64

log_cmd ./runme_xeon64
